package factory;

/**
 * 工厂模式的核心就是通过反射的方法创建对象提高灵活性
 */
public class FruitsFactory extends FruitsFactoryImpl {

    @Override
    public <T extends Fruits> T createFruits(Class<T> c) {
        Fruits fruits=null;
        try {
            fruits= (T)Class.forName(c.getName()).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (T)fruits;
    }
}
